import java.util.Random;

public class Member implements Comparable<Member>  {
   final public static Random	rdm = new Random();
   protected int	ID  = 0; 
   protected String	fName = null,
	     		lName = null;
   public    Member()  { set() ;}
   public    Member( Member m ) {
    	ID= m.ID;
	// fName = m.fName;  // There is a aliasing problem.
	fName = new String(m.fName) ; 
	lName = new String(m.lName) ;
   }
   public void set ( ) {
	ID    = rdm.nextInt( 999999999 - 10000000 + 1 ) + 10000000;
	fName = Names.firstName[ rdm.nextInt(Names.firstName.length)];   
	lName = Names.lastName [ rdm.nextInt(Names. lastName.length)];   
   }

   public String toString( ) { return toString ( true ); }
   public String toString( boolean lab ) {
	return (lab? "MEM " : "" ) + String.format("%03d-%02d-%04d %12s %-12s", 
		ID/1000000, ID/1000 % 100, ID % 10000, lName, fName);
   }

   public String toTableRow(  ) { return toTableRow ( false ); }

   public String toTableRow( boolean partial ) {
	return  ( ! partial ? "\n    <TR>\n" : "" ) 
	        +  String.format(  "\t<TD width=100>%03d-%02d-%04d</TD><TD align=right width=100>%s </TD><TD width=100> %s</TD>", 
					ID/1000000, ID/1000 % 100, ID % 10000, lName, fName)
	       + ( !partial ? "\n    </TR>\n" : "");
   }


   public int compareTo( Member m ) {
     return this.ID - m.ID;
   }
}